// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//


#pragma once

#include <cstdint>

namespace kumo::pollux::dwio::common {
    constexpr uint32_t SHORT_BYTE_SIZE = 2;
    constexpr uint32_t INT_BYTE_SIZE = 4;
    constexpr uint32_t LONG_BYTE_SIZE = 8;

    constexpr uint64_t BASE_128_MASK = 0x7f;
    constexpr uint64_t BASE_256_MASK = 0xff;
    constexpr __int128_t INT128_BASE_256_MASK = 0xff;

    // Timezone constants
    constexpr int64_t SECONDS_PER_HOUR = 60 * 60;
    // Timezone offset of PST from UTC.
    constexpr int64_t TIMEZONE_OFFSET = (8 * SECONDS_PER_HOUR);
    // ORC base epoch: 2015-01-01 00:00:00 in UTC, as seconds from UNIX epoch.
    constexpr int64_t UTC_EPOCH_OFFSET = 1420070400;
    // ORC actual epoch: 2015-01-01 00:00:00 in PST
    // (2015-01-01 08:00:00 in GMT)
    constexpr int64_t EPOCH_OFFSET = UTC_EPOCH_OFFSET + TIMEZONE_OFFSET;

    // Maximum nanos possible.
    constexpr int64_t MAX_NANOS = 999'999'999;
    // Minimum seconds that can be written using the Timestamp Writer.
    // 1 is reduced to epoch, as writer adds 1 for negative seconds.
    constexpr int64_t MIN_SECONDS = INT64_MIN + (EPOCH_OFFSET - 1);
} // namespace kumo::pollux::dwio::common
